package com.xiang.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiang.action.AccountAction;
import com.xiang.doman.Account;
import com.xiang.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountService extends ServiceImpl<AccountMapper, Account> {
    @Autowired
    AccountAction accountAction;
    public void reduceMoney(int accountId, double amount) {

        //TCC 按正常业务调用
        accountAction.prepare(null,amount,accountId);


//        Account account = getById(countId);
//        if(account.getMoney() < amount){
//            throw new RuntimeException("余额不足！");
//        }
//
//        account.setMoney(account.getMoney() - amount);
//        updateById(account);

    }
}
